package com.xuelang.pipeline.worker.entry.deployment;

import com.xuelang.pipeline.worker.app.deployment.DeploymentService;
import com.xuelang.pipeline.worker.client.common.result.ApiResult;
import com.xuelang.pipeline.worker.client.deployment.IDeploymentService;
import com.xuelang.pipeline.worker.client.deployment.dto.DeployQueryDTO;
import io.kubernetes.client.openapi.models.V1DeploymentList;
import io.kubernetes.client.openapi.models.V1Scale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liuyuan.ly
 * @since 2024/8/8 17:01
 */
@RestController
@RequestMapping("/pipeline/worker/")
public class DeploymentController implements IDeploymentService {
    @Autowired
    private DeploymentService deploymentService;

    @Override
    public ApiResult<V1DeploymentList> getDeploymentList(DeployQueryDTO queryDTO) {
        return ApiResult.success(deploymentService.getDeploymentList(queryDTO));
    }

    @Override
    public ApiResult<V1Scale> patchDeployment(DeployQueryDTO queryDTO) {
        return ApiResult.success(deploymentService.patchDeployment(queryDTO));
    }

    @Override
    public ApiResult<List<String>> listAvailableDeploymentName(DeployQueryDTO queryDTO) {
        return ApiResult.success(deploymentService.listAvailableDeploymentName(queryDTO));
    }
}
